<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<link rel="stylesheet" href="css/weui.css">
		<link rel="stylesheet" href="css/jquery-weui.css">
		<link rel="stylesheet" href="css/style.css">
		<style>
			#img {
				margin-left: -100px;
			}
			
			.unlogin-text {
				padding: 45px 30px;
			}
		</style>
	</head>

	<body>
		<div class="overlay open">
			<div class="overlay-content scrolling unlogin">
				<div class="unlogin-bg-wrapper"></div>
				<div class="unlogin-text">
					<img id="img" style="display: none;" />
					<div class="unlogin-text">
						<div class="logo">
							<img src="images/logoHMS-v3.png" alt="">
						</div>
					</div>
					<div class="weui-cells f15 unlogin-main">
						<div class="weui-cell">
							<div class="weui-cell__bd">
								<input class="weui-input" type="tel" placeholder="手机号码" maxlength="11" id="number">
							</div>
						</div>
						<div class="weui-cell">
							<div class="weui-cell__bd">
								<input class="weui-input" type="password" placeholder="登录密码" maxlength="18" id="password">
							</div>
						</div>
					</div>
					<div class="unlogin-btn">
						<a href="#" class="weui-btn weui-btn_primary" onclick="Login()">登录</a>
					</div>
					<div class="foot">
						<a href="register.html">　　注册</a> |
						<a href="forgetThePassword.html">忘记密码？</a>
					</div>
				</div>

			</div>
		</div>
		<div id="c1"></div>
		<script src="js/jquery.min.js"></script>
		<script src="js/jquery-weui.min.js"></script>
		<script src="controller/base.js"></script>
		<script src="js/require.min.js" data-main="controller/login.js"></script>
	</body>

	<script>
		var wgtVer = null;

		function plusReady() {
			// 获取本地应用资源版本号
			plus.runtime.getProperty(plus.runtime.appid, function(inf) {
				wgtVer = inf.version;
			});
		}
		if(window.plus) {
			plusReady();
		} else {
			document.addEventListener('plusready', plusReady, false);
		}
		// 检测更新
		var checkUrl = ip + "appDownloads/wgt.txt";

		function checkUpdate() {
			plus.nativeUI.showWaiting("检测更新...");
			var xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function() {
				switch(xhr.readyState) {
					case 4:
						plus.nativeUI.closeWaiting();
						if(xhr.status == 200) {
							var newVer = xhr.responseText;
							if(wgtVer && newVer && (wgtVer != newVer)) {
								downWgt(); // 下载升级包
							} else {

							}
						} else {

						}
						break;
					default:
						break;
				}
			}
			xhr.open('GET', checkUrl);
			xhr.send();
		}
		// 下载wgt文件
		var wgtUrl = ip + "appDownloads/H5039C523.wgt";

		function downWgt() {
			plus.nativeUI.showWaiting("下载更新文件...");
			plus.downloader.createDownload(wgtUrl, {
				filename: "_doc/update/"
			}, function(d, status) {
				if(status == 200) {
					installWgt(d.filename); // 安装wgt包
				} else {
					plus.nativeUI.alert("下载更新文件失败！");
				}
				plus.nativeUI.closeWaiting();
			}).start();
		}
		// 更新应用资源
		function installWgt(path) {
			plus.nativeUI.showWaiting("安装更新文件...");
			plus.runtime.install(path, {}, function() {
				plus.nativeUI.closeWaiting();
				plus.runtime.restart();
				plus.runtime.restart();
			}, function(e) {
				plus.nativeUI.closeWaiting();
				plus.nativeUI.alert("安装更新文件失败[" + e.code + "]：" + e.message);
			});
		}
		setTimeout("checkUpdate()", 1000);
	</script>

</html>